//
//  RecordCell.m
//  体育
//
//  Created by  on 2022/10/24.
//

#import "RecordCell.h"
@interface RecordCell()
@property (strong, nonatomic) IBOutlet UILabel *date;
@property (strong, nonatomic) IBOutlet UILabel *score;
@property (strong, nonatomic) IBOutlet UILabel *rangfen;
@property (strong, nonatomic) IBOutlet UILabel *total;
@property (strong, nonatomic) IBOutlet UILabel *league;
@property (strong, nonatomic) IBOutlet UILabel *halfScore;
@property (strong, nonatomic) IBOutlet UILabel *winOrLose;
@property (strong, nonatomic) IBOutlet UILabel *daxiao;
@property (strong, nonatomic) IBOutlet UILabel *home;
@property (strong, nonatomic) IBOutlet UILabel *from;

@end
@implementation RecordCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}
- (void)setModel:(Record *)model{
    _model = model;
    self.date.text = [NSDate transToDate:@"yyyy-MM-dd" :model.stamp];
    self.home.text = LS(model.home);
    self.from.text = LS(model.from);
    self.league.text = LS(model.league_name);
    self.score.text = [NSString stringWithFormat:@"%d-%d",model.score_home,model.score_from];
    self.halfScore.text = [NSString stringWithFormat:@"(%d-%d)",model.top_half_score_home,model.top_half_score_from];
    BOOL win = model.score_from + model.score_home + model.rang <= model.estimate_score;
    self.winOrLose.text = win ? LS(@"赢"):LS(@"输");
    self.daxiao.text = win ? LS(@"小"):LS(@"大");
    self.rangfen.text = [NSString stringWithFormat:@"%d",(int)model.rang];
    self.total.text = [NSString stringWithFormat:@"%d",(int)model.estimate_score];
    self.winOrLose.textHexColor  = win ? @"#E33A2F":@"#262729";
    self.rangfen.textHexColor  = win ? @"#E33A2F":@"#262729";
    self.daxiao.textHexColor  = win ? @"#262729":@"#E33A2F";
    self.total.textHexColor  = win ? @"#262729":@"#E33A2F";
    self.home.textHexColor = [self.title isEqualToString:self.home.text] ? @"#E33A2F":@"#262729";
    self.from.textHexColor = [self.title isEqualToString:self.from.text] ? @"#E33A2F":@"#262729";
    
    self.score.hidden = [self.title isEqualToString:LS(@"未来几场")];
    self.halfScore.hidden = self.score.hidden;
    self.rangfen.hidden = self.score.hidden;
    self.winOrLose.hidden = self.score.hidden;
    self.daxiao.hidden = self.score.hidden;
    self.total.hidden = self.score.hidden;
    
    
}
@end
